<% title_tag [params[:q], t('common.search_result')].join(' · ') %>
<div class="search-results card card-lg">
  <div class="card-body">
    <div class="card-title d-flex justify-content-between">
      <div>
        关于 “<%= params[:q] %>” 的搜索结果 <span class="counter">共 <%= @search.query_results.size %> 条</span>
      </div>

      <div>
        <%=
        class_names = "btn btn-default btn-sm button-filter-excellent-topic"
          icon = '<i class="fa fa-eye-slash"></i>'
          if params[:excellent] == "1"
            link_to raw("#{icon} <span>查看全部</span>"), "#", title: "", "data-id" => params[:q], class: "#{class_names} active"
          else
            link_to raw("#{icon} <span>只看精华</span>"), "#", title: "", "data-id" => params[:q], class: class_names
          end
        %>
      </div>

    </div>
    <% if @result.size == 0 %>
      <div class="no-result">没有搜索到任何有关 “<%= params[:q]%>” 的内容</div>
    <% else %>
      <% @result.each do |doc| %>
        <% partial_view_name = doc.searchable_type.downcase -%>
        <% partial_view_name = 'user' if partial_view_name == 'team' %>
        <% partial_view_name = 'topic' if partial_view_name == 'article' %>
        <%= render partial: partial_view_name, locals: { item: doc.searchable, hit: doc } %>
      <% end %>
    <% end %>
    <%= paginate @result %>
  </div>
</div>
